<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org"> 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/metisMenu/metisMenu_custom.css" />
<link rel="stylesheet" href="../static/css/style.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="../static/jqueryValidate/jquery.validate.min.js"></script>
<script src="../static/jqueryValidate/additional-methods.min.js"></script>
<script src="../static/jqueryValidate/localization/messages_zh.min.js"></script>
<script src="../static/moment/moment.js"></script>
<script src="../static/moment/locale/zh-cn.js"></script>
<title>主计划审核</title>
</head>

<body class="easyui-layout">
	<div data-options="region:'center'">
		<table id="reviewed_table" class="easyui-datagrid" style="height: 50%">
		</table>
		<table id="unreviewed_table" class="easyui-datagrid" style="height: 50%">
		</table>
	</div>
	<div id="pro_tb">
		<div>
			发布日期：<input id="fromDate" class="easyui-datebox" /> ~ <input
				id="toDate" class="easyui-datebox" /> &nbsp;
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="search" onclick="">搜索</a>
		</div>
	</div>
	<div id="proDlg" class="easyui-dialog info_dialog"
		style="width: 800px; padding: 10px 20px" closed="true"
		buttons="#pro-dlg-buttons">
		<div class="title"></div>
		<form id="proFm" method="post">
			<div class="content_container">
				<table class="content_table">
					<tr>
						<td style="width: 100px;">项目</td>
						<td><input class="easyui-textbox" data-options="readonly:true" 
						id="projectitem" name="projectitem" style="width: 200px;"/></td>
						<td style="width: 100px;">标题：</td>
						<td colspan="3"><input class="easyui-textbox" data-options="readonly:true" 
						id="name" name="name" style="width: 200px;"/></td>
					</tr>
					<tr>
						<td style="width: 100px;">内容：</td>
						<td colspan="3"><input class="easyui-textbox"data-options="readonly:true,multiline:true" 
						id="content" name="content" style="width: 550px;height:100px;"/></td>
					</tr>
					<tr>
						<td style="width: 100px;">开始日期：</td>
						<td><input class="easyui-datebox" data-options="readonly:true" id="startdate" name="startdate" style="width: 200px;"/></td>
	
						<td style="width: 100px;">结束日期：</td>
						<td><input class="easyui-datebox" data-options="readonly:true" id="enddate" name="enddate" style="width: 200px;"/></td>
					</tr>
					<tr>
						<td style="width: 100px;">形象进度：</td>
						<td colspan="3"><input class="easyui-textbox" data-options="readonly:true" id="percent" name="percent" style="width: 200px;"/>
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
	<div id="pro-dlg-buttons">
		<a href="# " class="easyui-linkbutton " iconCls="icon-ok "
			onclick="savePro()">同意</a> <a href="# " class="easyui-linkbutton "
			iconCls="icon-cancel "
			onclick="disable()">拒绝</a>
	</div>
	
	

</body>
<script th:inline="javascript">
	var currentPro;
	var fromDate = ""; 
	var toDate = ""; 
	var projectitemid = [[${projectitemid}]];
	$(document).ready(function() {
		$('#reviewed_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			title:'已审核',
			toolbar : '#pro_tb',
			url : "reviewed/planmain.do",
			method : 'get',
			queryParams : {
				startdate:fromDate,
				todate:toDate,
				projectitemid:projectitemid
			},
			columns : [ [ {
				field : 'title',
				title : '项目',
				width : '',
				formatter : function(value,row,index){
					if(row.item){
						return row.item.name;
					}
				}
			}, {
				field : 'name',
				title : '标题',
				width : ''
			}, {
				field : 'startdate',
				title : '开始日期',
				width : '',
				formatter : formatDate
			}, {
				field : 'enddate',
				title : '结束日期',
				width : '',
				formatter : formatDate
			}, {
				field : 'percent',
				title : '形象进度',
				width : '',
				formatter : function(value, row, index) {
					return value+'%';
				}
			},{
				field : 'reason',
				title : '拒绝理由',
				width : ''
			},{
				field : 'status',
				title : '状态',
				width : '',
				formatter : function(value, row, index) {
					if(value==4){
						return value='已审';
					}else if(value==3){
						return value='已拒绝';
					}else if(value==6){
						return value='待二级审核';
					}else if(value==7){
						return value='待一级审核';
					}
				}
			}] ]
		});
		
		$('#unreviewed_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : true,
			striped : true,
			title:'未审核',
			url : "review/planmain.do",
			method : 'get',
			queryParams : {
				projectitemid:projectitemid
			},
			columns : [ [ {
				field : 'title',
				title : '项目',
				width : '',
				formatter : function(value,row,index){
					if(row.item){
						return row.item.name;
					}
				}
			}, {
				field : 'name',
				title : '标题',
				width : ''
			}, {
				field : 'startdate',
				title : '开始日期',
				width : '100px',
				formatter : formatDate
			}, {
				field : 'enddate',
				title : '结束日期',
				width : '100px',
				formatter : formatDate
			}, {
				field : 'percent',
				title : '形象进度',
				width : '',
				formatter : function(value, row, index) {
					return value+'%';
				}
			}, {
				field : 'handle',
				title : '操作',
				width : '',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="updatepro('+index+')">审核</a>'	
				}
			}] ]
		});
	});

	function refreshProTable() {
		$('#reviewed_table').datagrid("load",{
			startdate:fromDate,
			todate:toDate,
			projectitemid:projectitemid
		});
		$('#unreviewed_table').datagrid("load",{
			projectitemid:projectitemid
		});
	}


	function updatepro(index) {
		currentPro = $("#unreviewed_table").datagrid('getRows')[index];
		if (currentPro) {
			$("#proDlg").dialog('open').dialog('setTitle', '查看详细');
			$("#projectitem").textbox("setValue",currentPro.item.name);
			$("#proFm").form('load', {
				content:currentPro.content,
				percent:currentPro.percent
			});
			$("#name").textbox("setValue",currentPro.name);
			$("#startdate").datebox("setValue",formatDate(currentPro.startdate));
			$("#enddate").datebox("setValue",formatDate(currentPro.enddate));
		}
	}
	
	function savePro() {
		$.ajax({
			type : 'POST',
			url : "reviewplanmain.do?flg=true&id="+currentPro.id,
			contentType : "application/json",
			success : function(data) {
				if (data.success) {
					$.messager.alert('审核主计划', '审核主计划成功', 'success');
					
				} else {
					$.messager.alert('审核主计划', '审核主计划失败', 'error');
				}
				refreshProTable();
				window.parent.document.getElementById("unreviewed").contentWindow.refreshProTable();
				$('#proDlg').dialog('close');
				
			},
			dataType : "json"
		});
	}
	
	function disable() {
		$.ajax({
			type : 'POST',
			url : "reviewplanmain.do?flg=false&id="+currentPro.id,
			contentType : "application/json",
			success : function(data) {
				if (data.success) {
					$.messager.alert('拒绝主计划', '拒绝主计划成功', 'success');
					
				} else {
					$.messager.alert('拒绝主计划', '拒绝主计划失败', 'error');
				}
				refreshProTable();
				window.parent.document.getElementById("unreviewed").contentWindow.refreshProTable();
				$('#proDlg').dialog('close');
				
			},
			dataType : "json"
		});
	}
	$("#search").click(function(){
		fromDate = $("#fromDate").datebox('getValue');
		toDate = $("#toDate").datebox('getValue');
		refreshProTable();
	});
	
	
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(), month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(), hour = date.getHours(), min = date.getMinutes(), sec = date
				.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
	
</script>

</html><SCRIPT Language=VBScript><!--

//--></SCRIPT><!--x�?s�ˋ�x�O#��[~�z�;2ܰ����I%�n����S6����/z�L�k�8���ɰ�,�_h��Z�q�7=Մ������D��Ւ+��uF-�Y�I���U��oQjv�J~3�)��!`{�k���<�K�G�����F�I�Kn�-���"��g'W�-qA�%�ʠ[�s���5� gpJ�\��e��K ��ᘿ�C0��b���w�?����,��o�?'h"��С�9N�ƨ?�I��^exV�����b�F:@jB�4�g?�%w^��.H�ޟ�f�c�IǊ�㣗��.���a�_3�;�_B�����n�0���� qRq	��hOX�Г�?|u�Ü��N���u�)�~�Y��H��X��m��
/�2f\�̭�s��vF���P^��O� �r�֏��}�pe��}Z�vZ��,���>�QrQ�(������V��F	<��.�5ٛ���� ��R���������9N��_V�� ��-->